{__NOLAYOUT__}
<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>微美风铃-用户注册</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="msapplication-tap-highlight" content="no">
		<meta content="telephone=no" name="format-detection">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<script src="__PUBLIC__/Static/js/zepto.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="__PUBLIC__/Static/js/simapp.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/Static/css/simcss.css" />
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/Static/css/buttons.css" />
		<style type="text/css">
			.wrapper {
				width: 100%;
				text-align: center;
			}
			.wrapper-inset {
				text-align: center;
				margin-left: 10px;
				margin-right: 10px;
			}
			.sim-input {
				border: solid 1px #008855;
				padding: 5px 3px;
				border-radius: 3px;
				margin: 5px auto;
			}
			.sim-block {
				display: block;
				width: 100%;
				box-sizing: border-box;
			}
			#success{
				display: none;
				border: #060 solid 1px;
				border-radius: 5px;
				text-align: left;
				padding: 10px;
			}
		</style>
	</head>

	<body>
		<div class="wrapper-inset">
			<h2>微美风铃客户注册</h2>
			<hr>
			<div id="register">
				<input type="text" id="name" name="name" class="sim-input sim-block" placeholder="请输入公司名称" />
				<input type="text" id="contacts" name="contacts" class="sim-input sim-block" placeholder="请输入联系姓名" />
				<input type="text" id="tel" name="tel" class="sim-input sim-block" placeholder="请输入联系电话" />
				<input type="text" id="email" name="email" class="sim-input sim-block" placeholder="请输入登录邮箱" />
				<input type="text" id="password" name="password" class="sim-input sim-block" placeholder="请输入登录密码" />
				<a id="submit" class="button button-block button-rounded button-flat-highlight">免费注册会员</a>
				<p><a href="http://mp.weixin.qq.com/s?__biz=MjM5NjQyMzIwMg==&mid=200898661&idx=1&sn=848091bdd624951bec2fc01643b1390d#rd">查看客户样例</a></p>
			</div>
			<div id="success">
				<p>恭喜您注册成功!</p>
				<p>请在电脑端登录后台进行简单的商城设置，然后就可以拥有一个强大的微分销商城了！</p>
				<p>后台地址：http://www.wmfl.cn/my</p>
				<p>登录邮箱：<span id="loginEmail"></span></p>
				<p>登录密码：<span id="loginPassword"></span></p>
			</div>
		</div>
		<script type="text/javascript">
			$(function() {
				$("#submit").click(function() {
					var othis = $(this);
					// 表单项
					var items = ['name', 'contacts', 'tel', 'email', 'password'];
					var values = {from:'mobile'};
					var ok = true;
					// 表单验证
					$.each(items, function(index, item) {
						var oItem = $("#" + item);
						var value = $.trim(oItem.val());
						if ( value == '') {
							simapp.toast(oItem.attr("placeholder"));
							oItem.focus();
							ok = false;
							return false;
						}
						values[item] = value;
					});
					
					if(!ok){
						return;
					}
					
					// 提交表单
					$.ajax({
						type:"POST",
						url:"__CONTROLLER__/saveCustomer",
						data:values,
						beforeSend: function(){
							othis.addClass('disabled');
							simapp.toast("正在提交注册……");
						},
						success: function(data){
							if(data.error==0){
								$('#register').hide();
								$("#loginEmail").html(values.email);
								$("#loginPassword").html(values.password);
								$("#success").show();
							}
							simapp.toast(data.msg);
						},
						error: function(){
							simapp.toast('服务器繁忙，请重试！');
						},
						complete: function(){
							othis.removeClass("disabled");
						}
					});
				});
			});
		</script>

	</body>

</html>